/**
 * created by 小卷毛, 2019-10-22 022
 * Copyright (c) 2019, 416143467@qq.com All Rights Reserved.
 * #                   *********                            #
 * #                  ************                          #
 * #                  *************                         #
 * #                 **  ***********                        #
 * #                ***  ****** *****                       #
 * #                *** *******   ****                      #
 * #               ***  ********** ****                     #
 * #              ****  *********** ****                    #
 * #            *****   ***********  *****                  #
 * #           ******   *** ********   *****                #
 * #           *****   ***   ********   ******              #
 * #          ******   ***  ***********   ******            #
 * #         ******   **** **************  ******           #
 * #        *******  ********************* *******          #
 * #        *******  ******************************         #
 * #       *******  ****** ***************** *******        #
 * #       *******  ****** ****** *********   ******        #
 * #       *******    **  ******   ******     ******        #
 * #       *******        ******    *****     *****         #
 * #        ******        *****     *****     ****          #
 * #         *****        ****      *****     ***           #
 * #          *****       ***        ***      *             #
 * #            **       ****        ****                   #
 */
package com.af.community.smart.utils

/**
 * 等比缩放
 * 将图缩略成宽度为 width，高度为 height，按长边优先
 */
fun String?.scaleImage(
    width: Int = 200,
    height: Int = 200
) =
    when {
        this@scaleImage.isNullOrEmpty() -> ""
        "oss-cn-beijing.aliyuncs.com" in this -> "${this}?x-oss-process=image/resize,m_lfit,h_${height},w_${width}"
        else -> this
    }